package com.jeomo.common.log.controller;

import com.jeomo.common.core.dto.PageQueryDto;
import com.jeomo.common.core.dto.PageResponseDto;
import com.jeomo.common.core.request.PageRequest;
import com.jeomo.common.core.result.CommonResult;
import com.jeomo.common.core.util.BeanCopyUtil;
import com.jeomo.common.core.vo.PageResponseVo;
import com.jeomo.common.log.service.ILogService;
import com.jeomo.common.log.vo.SysLogVo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 *
 * @author:Jackpot
 * @create 2020-09-03 10:05
 * @description:
 */
@RestController
@RequestMapping("/syslog")
public class SysLogController {

    @Resource
    private ILogService logService;

    @PostMapping("/page")
    public CommonResult<PageResponseVo<SysLogVo>> page(@RequestBody PageRequest pageRequest) {
        PageQueryDto dto = BeanCopyUtil.copyProperties(pageRequest, PageQueryDto.class);
        PageResponseDto responseDto = logService.pageSearch(dto);
        PageResponseVo<SysLogVo> responseVo = BeanCopyUtil.copyPageProperties(responseDto, SysLogVo.class);
        return CommonResult.success(responseVo);
    }
}
